package top.btcmarket;

import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang3.StringUtils;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

public class TestJson {

	public static void main(String[] args) {
		String ss = "[{\"avatar\":\"/img/20180623/Ptp7selcT4wci4SU.jpg\",\"complaintFlag\":\"0\",\"createTime\":\"2018-06-27 11:33:46.0\",\"id\":8833505226420280241,\"msgDisturbFlag\":\"0\",\"nikeName\":\"${userName}\",\"originType\":\"0\",\"relationId\":8740064801143906002,\"shortName\":\"${userName}\",\"showFlag\":\"0\",\"showFriendFlag\":\"0\",\"starFlag\":\"0\",\"status\":\"0\",\"topFlag\":\"0\",\"topTime\":\"2018-06-27 11:33:46.0\",\"updateTime\":\"2018-06-27 11:33:46.0\",\"userId\":8651729870448919273},{\"avatar\":\"/img/20180623/Ptp7selcT4wci4SU.jpg\",\"complaintFlag\":\"0\",\"createTime\":\"2018-06-27 11:33:46.0\",\"id\":8833505233954237429,\"msgDisturbFlag\":\"0\",\"nikeName\":\"${userName}\",\"originType\":\"0\",\"relationId\":8740064820433461507,\"shortName\":\"${userName}\",\"showFlag\":\"0\",\"showFriendFlag\":\"0\",\"starFlag\":\"0\",\"status\":\"0\",\"topFlag\":\"0\",\"topTime\":\"2018-06-27 11:33:46.0\",\"updateTime\":\"2018-06-27 11:33:46.0\",\"userId\":8651729870448919273},{\"avatar\":\"/img/20180623/Ptp7selcT4wci4SU.jpg\",\"complaintFlag\":\"0\",\"createTime\":\"2018-06-27 11:33:46.0\",\"id\":8833505243624378858,\"msgDisturbFlag\":\"0\",\"nikeName\":\"${userName}\",\"originType\":\"0\",\"relationId\":8740064839709619737,\"shortName\":\"${userName}\",\"showFlag\":\"0\",\"showFriendFlag\":\"0\",\"starFlag\":\"0\",\"status\":\"0\",\"topFlag\":\"0\",\"topTime\":\"2018-06-27 11:33:46.0\",\"updateTime\":\"2018-06-27 11:33:46.0\",\"userId\":8651729870448919273},{\"avatar\":\"/img/20180623/Ptp7selcT4wci4SU.jpg\",\"complaintFlag\":\"0\",\"createTime\":\"2018-06-27 11:33:46.0\",\"id\":8833505252976811693,\"msgDisturbFlag\":\"0\",\"nikeName\":\"${userName}\",\"originType\":\"0\",\"relationId\":8740064859151371731,\"shortName\":\"${userName}\",\"showFlag\":\"0\",\"showFriendFlag\":\"0\",\"starFlag\":\"0\",\"status\":\"0\",\"topFlag\":\"0\",\"topTime\":\"2018-06-27 11:33:46.0\",\"updateTime\":\"2018-06-27 11:33:46.0\",\"userId\":8651729870448919273}]";
		
		//{"avatar":"/img/20180623/Ptp7selcT4wci4SU.jpg","complaintFlag":"0","createTime":"2018-06-27 11:33:46.0","id":8833505226420280241,"msgDisturbFlag":"0","nikeName":"${userName}","originType":"0","relationId":8740064801143906002,"shortName":"${userName}","showFlag":"0","showFriendFlag":"0","starFlag":"0","status":"0","topFlag":"0","topTime":"2018-06-27 11:33:46.0","updateTime":"2018-06-27 11:33:46.0","userId":8651729870448919273},{"avatar":"/img/20180623/Ptp7selcT4wci4SU.jpg","complaintFlag":"0","createTime":"2018-06-27 11:33:46.0","id":8833505233954237429,"msgDisturbFlag":"0","nikeName":"${userName}","originType":"0","relationId":8740064820433461507,"shortName":"${userName}","showFlag":"0","showFriendFlag":"0","starFlag":"0","status":"0","topFlag":"0","topTime":"2018-06-27 11:33:46.0","updateTime":"2018-06-27 11:33:46.0","userId":8651729870448919273},{"avatar":"/img/20180623/Ptp7selcT4wci4SU.jpg","complaintFlag":"0","createTime":"2018-06-27 11:33:46.0","id":8833505243624378858,"msgDisturbFlag":"0","nikeName":"${userName}","originType":"0","relationId":8740064839709619737,"shortName":"${userName}","showFlag":"0","showFriendFlag":"0","starFlag":"0","status":"0","topFlag":"0","topTime":"2018-06-27 11:33:46.0","updateTime":"2018-06-27 11:33:46.0","userId":8651729870448919273},{"avatar":"/img/20180623/Ptp7selcT4wci4SU.jpg","complaintFlag":"0","createTime":"2018-06-27 11:33:46.0","id":8833505252976811693,"msgDisturbFlag":"0","nikeName":"${userName}","originType":"0","relationId":8740064859151371731,"shortName":"${userName}","showFlag":"0","showFriendFlag":"0","starFlag":"0","status":"0","topFlag":"0","topTime":"2018-06-27 11:33:46.0","updateTime":"2018-06-27 11:33:46.0","userId":8651729870448919273}
		
		JSONArray parseArray = JSONObject.parseArray(ss);
		
		System.out.println("parseArray.size()  "+parseArray.size());
		
		Integer dd = 1000 ;
		int dds = 1000 ;
		System.out.println(dd == dds);
		
		
		String jjss = "{\"address\":\"XsPKge6JpdenNFZGJtKZjf8qaXSEeXux4E\",\"transactions\":[{\"from\":[{\"address\":null,\"value\":\"0\"}],\"to\":[{\"address\":\"XsqziWa7sJZFLA6LkpF7gYEFtR2PNeCA8N\",\"value\":\"167396574\"},{\"address\":\"XsPKge6JpdenNFZGJtKZjf8qaXSEeXux4E\",\"value\":\"167396563\"}],\"timestamp\":\"1531007728\",\"hash\":\"1ba8ce434c77351e2f50697467f37b0bf36934615565ff2a539f949ee957bf29\",\"receive\":\"167396563\"},{\"from\":[{\"address\":\"XsPKge6JpdenNFZGJtKZjf8qaXSEeXux4E\",\"value\":\"167343901\"},{\"address\":\"XsPKge6JpdenNFZGJtKZjf8qaXSEeXux4E\",\"value\":\"167396223\"},{\"address\":\"XsPKge6JpdenNFZGJtKZjf8qaXSEeXux4E\",\"value\":\"167304209\"},{\"address\":\"XsPKge6JpdenNFZGJtKZjf8qaXSEeXux4E\",\"value\":\"167284730\"}],\"to\":[{\"address\":\"XbyB1CffJtevfEnzki9veKWPYkHsWdfjqL\",\"value\":\"669328265\"}],\"timestamp\":\"1530711999\",\"hash\":\"48b0f5d1ed2b2b5c0605254af150a59a5dc3f95ef8f635ea0aaae2573c014e8d\",\"receive\":\"-669329063\"},{\"from\":[{\"address\":null,\"value\":\"0\"}],\"to\":[{\"address\":\"XsqziWa7sJZFLA6LkpF7gYEFtR2PNeCA8N\",\"value\":\"167304221\"},{\"address\":\"XsPKge6JpdenNFZGJtKZjf8qaXSEeXux4E\",\"value\":\"167304209\"}],\"timestamp\":\"1530302605\",\"hash\":\"2ce2c7d11b54bf68259ae396f1db71998d79b1ce3944f30ec093d5349d3e9b3e\",\"receive\":\"167304209\"},{\"from\":[{\"address\":null,\"value\":\"0\"}],\"to\":[{\"address\":\"XuTpGdNTjXPk8NMskSTTQR316u7Bqephxy\",\"value\":\"163997027\"},{\"address\":\"XsPKge6JpdenNFZGJtKZjf8qaXSEeXux4E\",\"value\":\"167343901\"},{\"address\":\"Xj4rb2EcCFKhcTksDktWCMNBA5RnrSrCMx\",\"value\":\"3346878\"}],\"timestamp\":\"1529623043\",\"hash\":\"0c47cf2c4a83b14e8cdf6fb046229a09fcb72e4dfc53c6e099b5547015c931e7\",\"receive\":\"167343901\"},{\"from\":[{\"address\":null,\"value\":\"0\"}],\"to\":[{\"address\":\"XvhExSNNr97U1ZenWFjJmgD8wc7v88ZUF7\",\"value\":\"167284747\"},{\"address\":\"XsPKge6JpdenNFZGJtKZjf8qaXSEeXux4E\",\"value\":\"167284730\"}],\"timestamp\":\"1528927663\",\"hash\":\"63240321f741084a39c3e350957d4e728fde286c05e13c7710ec3f8eaa5bc6f1\",\"receive\":\"167284730\"}]}";
		JSONObject dataInfo = JSONObject.parseObject(jjss);
		System.out.println(dataInfo.toJSONString());
		
		
		UserFriendship ufs = new UserFriendship();
		ufs.setAvatar("dsdsd");
		ufs.setCreateTime("sdsdsd");
		
		
		 JSONObject uInfo = new JSONObject();
         uInfo.put("nickname", "nickname");
         uInfo.put("avatar", "avatar");
         uInfo.put("msg", "msg");
         
         
        
         
		 String jsonString = JSONObject.toJSONString(ufs);
		 System.out.println(jsonString);
		 
		 JSONObject parse = (JSONObject)JSONObject.parse(jsonString);
		 if(parse != null){
			 parse.put("nickname", "nickname");
			// parse.put("avatar", "avatar");
			 parse.put("msg", "msg");
		 }
		 System.out.println(parse.toJSONString());
		 
		 
		 Set<String> hh = new HashSet<>();
		 hh.add("0x007821b9a9d1ADe9ed44Ac32A61b2DBB44337cbb");
		 hh.add("0xa1dacb7d193259724c59a3e497e881089af2decd");
		 
		 JSONObject uInfo1 = new JSONObject();
		 String[] ssw = {"0x007821b9a9d1ADe9ed44Ac32A61b2DBB44337cbb","0xa1dacb7d193259724c59a3e497e881089af2decd"};
		 
//		 uInfo1.put("addrs", ssw);
		 uInfo1.put("addrs", hh.toArray());
		 System.out.println(uInfo1.toJSONString());
		 
		 
		 //DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
		 UserFriendship usship = new UserFriendship() ;
		 usship.setCreateTime(GetUTCTimeUtil.getUTCDateStr());
		
		 System.out.println(GetUTCTimeUtil.getUTCDateStr());
		 System.out.println(GetUTCTimeUtil.getUTCTimeStr());
		 System.out.println(GetUTCTimeUtil.getEndTime());
		 
		 String ssss = "2018-09-11 11:12:23.0" ;
		 System.out.println(ssss.substring(0, ssss.length()-2));
		 System.out.println(truncatTime(ssss));
		 
		 String sss = "summerInfo\nrrrrr\nddfdfd\ndsdfsdf" ;
		 System.out.println(sss.replaceAll("\n", "<br>"));
		 
		 
	}
	
	public static String truncatTime(String time){
    	if(StringUtils.isNotBlank(time)){
    		return time.substring(0, time.length()-2);
    	}
    	return time;
    }
}
